﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mogre;

namespace WastedMechanics.CharState
{
    public abstract class CharStateIdle : CharState
    {
        public string AnimationName;
        public float Mass;
        public Vector3 Inertia;

        public CharStateIdle(Character chr,string animName)
            : base(chr)
        {
            AnimationName = animName;
        }

        public override void Enter()
        {            
            Character.SetAnimation(AnimationName);
            Character.Velocity = Vector3.ZERO; 
            Character.CanTurn = true;
            Character.RunAcceleration = 0;
        }        

        public override void Exit()
        {
            if (Mass != 0)
                Character.Body.SetMassMatrix(Mass, Inertia);
        }

        public override void MoveOrder(bool run)
        {
            if (run)
                Character.SwitchState(GetRunState());
            else
                Character.SwitchState(GetWalkState());
        }

        public override void JumpOrder()
        {
            Character.SwitchState(GetJumpStandState());
        }
  
        public override void Update()
        {            
            if (!Character.IsOnGround || Character.Body.Velocity.y < -3)
                Character.SwitchState(GetFallState());
        }

        public abstract CharState GetRunState();
        public abstract CharState GetWalkState();
        public abstract CharState GetJumpStandState();
        public abstract CharState GetFallState();

    }
}
